{% extends 'home.html' %}

{% block content %}

<form class="form-group" id="form" method="post">

    <div class="container">
        <div class="panel panel-primary ">
            <div class="panel-heading">仪器基础信息输入</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">
                        <table class="table table-condensed">
                            <tbody>
                                <tr>
                                    <th scope="row" style="text-align:center">仪器名称</th>
                                    <td colspan="2"><input name="name" type="text" value="卡尔费休库仑法水分仪" id="name"></td>
                                    <th style="text-align:center">仪器接收编号</th>
                                    <td colspan="2"><input name="A1PH_Received02" type="text"
                                            value="{{ A1PH_Received02 }}" readonly="readonly" id="c_number"
                                            style="background-color:#F3F3F3;height:25px; width:300px">
                                    </td>
                                </tr>

                                <tr>
                                    <th scope="row" style="text-align:center">型号/规格</th>
                                    <td><input name="A1PH_ProdModel03" type="text" id="type"
                                            style="height:25px;width:240px" required>
                                    </td>
                                    <th style="text-align:center">仪器序列号</th>
                                    <td><input name="A1PH_SN04" type="text" id="snr" style="height:25px">
                                    </td>
                                    <!-- ... existing code ... -->
                                    <th style="text-align:center">环境条件</th>
                                    <td>
                                        <input name="A1PH_Wd11" type="text" id="A1PH_Wd11"
                                            style="height:25px; width:50px" onblur="formatToOneDecimal(this)">&nbsp;°C
                                        &nbsp;&nbsp;
                                        <input name="A1PH_Sd12" type="text" id="A1PH_Sd12"
                                            style="height:25px; width:50px" onblur="formatToOneDecimal(this)">&nbsp;%RH
                                        <script>
                                            function formatToOneDecimal(inputElement) {
                                                if (inputElement.value !== '') {
                                                    const value = parseFloat(inputElement.value);
                                                    if (!isNaN(value)) {
                                                        inputElement.value = value.toFixed(1);
                                                    }
                                                }
                                            }

                                            // 页面加载时也格式化已有的值
                                            document.addEventListener('DOMContentLoaded', function () {
                                                formatToOneDecimal(document.getElementById('A1PH_Wd11'));
                                                formatToOneDecimal(document.getElementById('A1PH_Sd12'));
                                            });
                                        </script>
                                    </td>
                                    <!-- ... existing code ... -->
                                </tr>
                                <tr>
                                    <th style="text-align:center" scope="row">校准依据</th>
                                    <td colspan="3">
                                        <input style="width:400px;" name="refer" value="JJG1044-2008卡尔·费休库伦法微量水分测定仪检定规程"
                                            readonly>
                                    <th style="text-align:center">校准日期</th>
                                    <td><input name="A1PH_Rq07" type="text" value="{{ date }}" id="date"
                                            style="height:25px"></td>
                                </tr>

                                <tr>
                                    <td colspan="6" class="panel-heading"
                                        style="height:20px;text-align:center;background-color:aliceblue">
                                        标准器及配套设备
                                    </td>
                                </tr>

                                <tr>
                                    <td colspan="6">
                                        <table class="table" id="tools">
                                            <tbody>
                                                <tr>
                                                    <th style="text-align:center">名称/型号</th>
                                                    <th style="text-align:center">编号</th>
                                                    <th style="text-align:center">测量范围</th>
                                                    <th style="text-align:center">批号/证书编号</th>
                                                    <th style="text-align:center">有效期</th>
                                                    <th style="text-align:center">校准机构</th>
                                                    <th style="text-align:center">计量特性</th>
                                                </tr>
                                                <tr>
                                                    <td><input name="BLPH_Xmxh16" type="text" id="BLPH_Xmxh16"
                                                            style="height:25px"></td>
                                                    <td><select name="BLPH_Bh17" id="mySelect"
                                                            style="height:30px;width:107px;">
                                                            <option value="0" selected="selected">==请选择==</option>
                                                            <option value="34828">34828</option>
                                                            <option value="GBW13513">GBW13513</option>

                                                        </select></td>
                                                    <td><input name="BLPH_FW_01" type="text" id="BLPH_FW_01"
                                                            style="height:25px;width:60px"></td>
                                                    <td><input name="BLPH_Jlzsbh18" type="text" id="BLPH_Jlzsbh18"
                                                            style="height:25px"></td>
                                                    <td><input name="BLPH_Yxrq19" type="text" id="BLPH_Yxrq19"
                                                            style="height:25px"></td>
                                                    <td><input name="BLPH_Yzjg20" type="text" id="BLPH_Yzjg20"
                                                            style="height:25px;width:100px">
                                                    </td>
                                                    <td><input name="BLPH_Zqddj21" type="text" id="BLPH_Zqddj21"
                                                            style="height:25px; width:140px"></td>

                                                </tr>
                                                <tr>
                                                    <td><input name="BLPH_Xmxh22" type="text" value="/" id="BLPH_Xmxh22"
                                                            style="height:25px"></td>
                                                    <td><select name="BLPH_Bh23" id="mySelect"
                                                            style="height:30px;width:107px;">
                                                            <option value="0" selected="selected">==请选择==</option>
                                                            <option value="34828">34828</option>
                                                            <option value="GBW13513">GBW13513</option>

                                                        </select></td>
                                                    <td><input name="BLPH_FW_02" type="text" value="/" id="BLPH_FW_02"
                                                            style="height:25px;width:60px"></td>
                                                    <td><input name="BLPH_Jlzsbh24" type="text" value="/"
                                                            id="BLPH_Jlzsbh24" style="height:25px"></td>
                                                    <td><input name="BLPH_Yxrq25" type="text" value="/" id="BLPH_Yxrq25"
                                                            style="height:25px"></td>
                                                    <td><input name="BLPH_Yzjg26" type="text" value="/" id="BLPH_Yzjg26"
                                                            style="height:25px;width:100px"></td>
                                                    <td><input name="BLPH_Zqddj27" type="text" value="/"
                                                            id="BLPH_Zqddj27" style="width:140px;height:25px">
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td><input name="BLPH_Xmxh28" type="text" value="/" id="BLPH_Xmxh28"
                                                            style="height:25px"></td>
                                                    <td><select name="BLPH_Bh29" id="mySelect"
                                                            style="height:30px;width:107px;">
                                                            <option value="0" selected="selected">==请选择==</option>
                                                            <option value="34828">34828</option>
                                                            <option value="GBW13513">GBW13513</option>

                                                        </select></td>
                                                    <td><input name="BLPH_FW_03" type="text" value="/" id="BLPH_FW_03"
                                                            style="height:25px;width:60px"></td>
                                                    <td><input name="BLPH_Jlzsbh30" type="text" value="/"
                                                            id="BLPH_Jlzsbh30" style="height:25px"></td>
                                                    <td><input name="BLPH_Yxrq31" type="text" value="/" id="BLPH_Yxrq31"
                                                            style="height:25px"></td>
                                                    <td><input name="BLPH_Yzjg32" type="text" value="/" id="BLPH_Yzjg32"
                                                            style="height:25px;width:100px"></td>
                                                    <td><input name="BLPH_Zqddj33" type="text" value="/"
                                                            id="BLPH_Zqddj33" style="width:140px;height:25px">
                                                    </td>

                                                </tr>

                                                <tr>
                                                    <td>生产厂商</td>
                                                    <td colspan="6"><input name="A1PH_Sccs52" type="text" value="梅特勒托利多"
                                                            id="A1PH_Sccs52" style="width:900px;height:25px"></td>


                                                </tr>
                                                <tr>
                                                    <td>证书单位</td>
                                                    <td colspan="6"><input name="A1PH_Zsdw53" type="text"
                                                            id="A1PH_Zsdw53" style="width:900px;height:25px"></td>


                                                </tr>
                                                <tr>
                                                    <td>证书地址</td>
                                                    <td colspan="6"><input name="A1PH_Zsdz54" type="text"
                                                            id="A1PH_Zsdz54" style="width:900px;height:25px"></td>


                                                </tr>
                                                <tr>
                                                    <td>校准地点</td>
                                                    <td colspan="6"><input name="A1PH_Xzdd55" type="text"
                                                            id="A1PH_Xzdd55" style="width:900px;height:25px"></td>

                                                </tr>

                                            </tbody>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>
        <div class="panel panel-primary">
            <div class="panel-heading">
                1. 通用技术要求
            </div>
            <div class="row">
                <div class="col-xs-3">外观及通电检查：</div>
                <div colspan="2" class="col-xs-3">符合 <input id="A1PH_Wgjcfh56" type="checkbox" name="A1PH_Wgjcfh56">
                </div>
                <div colspan="3" class="col-xs-3">不符合 <input id="A1PH_Wgjcbfh57" type="checkbox" name="A1PH_Wgjcbfh57">
                </div>
            </div>
        </div>
        <div class="panel panel-primary">
            <div class="panel-heading">2.示值误差（ug）</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">
                        <table name='myTable' id="myTable" class="table table-condensed form-group"
                            style="text-align: center;">
                            <thead>
                                <tr style="border-bottom: 2px solid rgb(51,122,183)">
                                    <th>元素</th>
                                    <th>检定点</th>
                                    <th>标准值<br>(W1-W2)
                                        g
                                    </th>
                                    <th>测量值<br>
                                        ug
                                    </th>
                                    <th>差值 ug</th>
                                    <th>示值误差<br>(平均值)
                                    </th>
                                    <th>技术要求
                                    </th>
                                </tr>
                            </thead>

                            <tbody>
                                <tr style="border-top: 2px solid rgb(51,122,183)" class="form-group">
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="text" style="height: 30px;" name="c1"></td>
                                    <td><input style="height: 30px;" name="c2"></td>
                                    <td><input style="height: 30px;" name="c3" id="c3"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>

                                <tr>
                                    <td><span type="text">标准水</span></td>
                                    <td><span type="text">10</span></td>
                                    <td><input type="text" style="height: 30px;" name="c4"></td>
                                    <td><input type="text" style="height: 30px;" name="c5"></td>
                                    <td><input type="number" style="height: 30px;" name="c6" id="c6"></td>
                                    <td><input type="text" style="height: 30px;" id="mean10" name="mean10"></td>
                                    <td><span type="text">≤ ± 3.5 μg</span></td>
                                </tr>

                                <tr style="border-bottom: 3px solid rgb(51,122,183)">
                                    <td><input type="hidden" style="height: 30px;" readonly="readonly"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="number" style="height: 30px;" name="c7"></td>
                                    <td><input type="number" style="height: 30px;" name="c8"></td>
                                    <td><input type="number" style="height: 30px;" id="c9"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>

                                <tr>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="number" style="height: 30px;" name="c10"></td>
                                    <td><input type="number" style="height: 30px;" name="c11"></td>
                                    <td><input type="number" style="height: 30px;" name="c12" id="c12"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>
                                <tr>
                                    <td><span type="text">标准水</span></td>
                                    <td><span type="text">100</span></td>
                                    <td><input type="number" style="height: 30px;" name="c13"></td>
                                    <td><input type="number" style="height: 30px;" name="c14"></td>
                                    <td><input type="number" style="height: 30px;" name="c15" id="c15"></td>
                                    <td><input type="number" style="height: 30px;" name="mean100" id="mean100"></td>
                                    <td><span type="text">≤ ± 8 μg</span></td>
                                </tr>

                                <tr style="border-bottom: 2px solid rgb(51,122,183)">
                                    <td><input type="hidden" style="height: 30px;" readonly="readonly"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="number" style="height: 30px;" name="c16"></td>
                                    <td><input type="number" style="height: 30px;" name="c17"></td>
                                    <td><input type="number" style="height: 30px;" name="c18" id="c18"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>

                                <tr>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="number" style="height: 30px;" name="c19"></td>
                                    <td><input type="number" style="height: 30px;" name="c20"></td>
                                    <td><input type="number" style="height: 30px;" name="c21" id="c21"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>

                                <tr>
                                    <td><span type="text">标准水</span></td>
                                    <td><span type="text">1000</span></td>
                                    <td><input type="number" style="height: 30px;" name="c22"></td>
                                    <td><input type="number" style="height: 30px;" name="c23"></td>
                                    <td><input type="number" style="height: 30px;" name="c24" id="c24"></td>
                                    <td><input type="number" style="height: 30px;" name="mean1000" id="mean1000">
                                    </td>
                                    <td><span type="text">≤ ± 53 μg</span></td>
                                </tr>

                                <tr style="border-bottom: 2px solid rgb(51,122,183)">
                                    <td><input type="hidden" style="height: 30px;" readonly="readonly"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="number" style="height: 30px;" name="c25"></td>
                                    <td><input type="number" style="height: 30px;" name="c26"></td>
                                    <td><input type="number" style="height: 30px;" name="c27" id="c27"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>

                                <tr>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="number" style="height: 30px;" name="c28"></td>
                                    <td><input type="number" style="height: 30px;" name="c29"></td>
                                    <td><input type="number" style="height: 30px;" name="c30" id="c30"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>

                                <tr>
                                    <td><span type="text">纯水</span></td>
                                    <td><span type="text">1</span></td>
                                    <td><input type="number" style="height: 30px;" name="c31"></td>
                                    <td><input type="number" style="height: 30px;" name="c32"></td>
                                    <td><input type="number" style="height: 30px;" name="c33" id="c33"></td>
                                    <td><input type="number" style="height: 30px;" name="mean1" id="mean1"></td>
                                    <td><span type="text">≤ ± 253 μg</span></td>
                                </tr>

                                <tr>
                                    <td><input type="hidden" style="height: 30px;" readonly="readonly">
                                    </td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="number" style="height: 30px;" name="c34"></td>
                                    <td><input type="number" style="height: 30px;" name="c35"></td>
                                    <td><input type="number" style="height: 30px;" name="c36" id="c36"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                    <td><input type="hidden" style="height: 30px;"></td>
                                </tr>


                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="panel panel-primary">
            <div class="panel-heading">3.示值重复性</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">
                        <table class="table table-bordered" id="myTable1">
                            <tbody>
                                <tr>
                                    <th style="vertical-align:middle;text-align:center">次数</th>
                                    <th style="vertical-align:middle;text-align:center">实测值/ug</th>
                                    <th style="vertical-align:middle;text-align:center">平均值/ug</th>
                                    <th style="vertical-align:middle;text-align:center">相对标准偏差 %</th>
                                    <th style="vertical-align:middle;text-align:center">技术要求</th>

                                </tr>
                                <tr>
                                    <td style="vertical-align:middle;text-align:center">1</td>
                                    <td><input name="b0" type="text" id="b0" style="width:140px; height:25px"></td>
                                    <td rowspan="6" style="vertical-align:middle;text-align:center">
                                        <input name="mean" type="number" id="mean">
                                    </td>
                                    <td rowspan="6" style="vertical-align:middle;text-align:center">
                                        <input name="rsd" type="number" id="rsd" readonly="readonly">
                                    </td>
                                    <td rowspan="6" style="vertical-align:middle;text-align:center">
                                        <div>≤3 %</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="vertical-align:middle;text-align:center">2</td>
                                    <td><input name="b1" type="text" id="b1" style="width:140px; height:25px">
                                    </td>
                                </tr>

                                <tr>
                                    <td style="vertical-align:middle;text-align:center">3</td>
                                    <td><input name="b2" type="text" id="b2" style="width:140px; height:25px">
                                    </td>

                                </tr>

                                <tr>
                                    <td style="vertical-align:middle;text-align:center">4</td>
                                    <td><input name="b3" type="text" id="b3" style="width:140px; height:25px">
                                    </td>

                                </tr>
                                <tr>
                                    <td style="vertical-align:middle;text-align:center">5</td>
                                    <td><input name="b4" type="text" id="b4" style="width:140px; height:25px">
                                    </td>

                                </tr>
                                <tr>
                                    <td style="vertical-align:middle;text-align:center">6</td>
                                    <td><input name="b5" type="text" id="b5" style="width:140px; height:25px"></td>
                                </tr>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="panel panel-primary">
            <div class="panel-heading">4.检查结果</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">
                        <table class="table table-hover">
                            <tbody>
                                <tr>
                                    <th style="vertical-align:middle;text-align:center">校准项目</th>
                                    <th style="vertical-align:middle;text-align:center">校准结果min</th>
                                    <th style="vertical-align:middle;text-align:center">技术要求</th>

                                </tr>

                                <tr>

                                    <td style="vertical-align:middle;text-align:center">电解速度</td>
                                    <td><input name="D0" type="text" id="D0" value="    min    s"
                                            style="width:300px; height:25px"></td>
                                    <td><input name="D1" type="text" id="D1" value="≤ 3 min" readonly="readonly"
                                            style="width:110px; height:25px;border-width: 0.5px; border-style: inset; background-color: #F3F3F3">
                                    </td>


                                </tr>
                                <tr>
                                    <td style="vertical-align:middle;text-align:center">零点平衡时间</td>
                                    <td><input name="D2" type="text" id="D2" value="    min    s"
                                            style="width:300px; height:25px"></td>
                                    <td><input name="D3" type="text" id="D3" value="≤ 2 min" readonly="readonly"
                                            style="width:110px; height:25px;border-width: 0.5px; border-style: inset; background-color: #F3F3F3">
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="panel panel-primary">
            <div class="panel-heading">本次校准结果的扩展不确定度 (<i>k</i>=2)</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <th colspan="2">示值误差 <i>Urel</i>= <input name="K0" type="text" id="K0"
                                                value="2.8" style="width:110px; height:25px">
                                            %
                                        </th>
                                        <!--<th>k = --><input name="K1" type="hidden" id="K1"
                                            style="width:110px; height:25px"> <!--</th>-->
                                    </tr>

                                </tbody>
                            </table>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-bordered">

                                <tbody>
                                    <tr>
                                        <th>校准员：</th>
                                        <td><input name="calibrator" type="text" id="calibrator"
                                                style="width:110px; height:25px;border-width: 0.5px; border-style: inset; background-color: #F3F3F3"
                                                value="{{ windows_user }}"></td>
                                        <th>核验员</th>
                                        <td><input name="inspector_Users" type="text" id="inspector_Users"
                                                style="width:110px; height:25px"></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <a class="btn btn-primary" onclick="showModal();">提交校准</a>
    <input value="取   消" id="Button3" class="btn btn-default">

</form>



<footer class="c-layout-footer c-layout-footer-3 c-bg-dark">
    <div class="c-postfooter">
        <div class="container">
            <div class="row">
                <div class="col-md-6 col-sm-12 c-col">
                    <p class="c-copyright c-font-grey">2023 ©卡尔费休库仑法水分仪校准校准
                        <span class="c-font-grey-3">All Rights Reserved.</span>
                    </p>
                </div>
            </div>
        </div>
    </div>
</footer>


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">

        <div class="modal-body">
            <div class="alert alert-danger alert-dismissible fade in" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4>注意!</h4>
                <p>请确认相关数据已经填写正确，提交后无法修改！！！</p>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <button type="button" class="btn btn-danger" onclick="confirmAdd();">
                        确定提交
                    </button>
                </div>
            </div>
        </div>


    </div>
</div>

{% endblock %}

{% block js %}
<script>

    function showModal() {

        $('#myModal').modal('show');
    }

    function confirmAdd() {
        //获取数据
        var data = $('#form').serialize();
        $.ajax({
            url: '/kfc/',
            type: 'POST',
            data: data,
            dataType: 'JSON',
            success: function (res) {
                if (res.status) {
                    location.href = 'http://127.0.0.1:8000/list/';
                    $('#myModal').modal('hide');
                } else {
                    alert('创建失败');
                }
            }
        })
    }


    $(document).ready(function () {

        calculateTotal();
        calmean();

        $('#tools tr:gt(0)').each(function () {
            $(this).find('td:eq(1) select').change(function () {
                var selectedValue = $(this).val();
                var title = $(this).parent().siblings().eq(0).find('input').first()
                var range = $(this).parent().siblings().eq(1).find('input').first()
                var certificate_number = $(this).parent().siblings().eq(2).find('input').first()
                var end_date = $(this).parent().siblings().eq(3).find('input').first()
                var cal_jigou = $(this).parent().siblings().eq(4).find('input').first()
                var property = $(this).parent().siblings().eq(5).find('input').first()

                $.ajax({
                    type: "GET",
                    url: "/tools/",  // 替换为您的URL
                    dataType: 'JSON',
                    data: {
                        'value': selectedValue,
                    },
                    success: function (data) {
                        // 假设返回的数据填充到input
                        var n = data.datalist;
                        title.val(n[0].fields.title);
                        range.val(n[0].fields.range);
                        certificate_number.val(n[0].fields.certificate_number);
                        end_date.val(n[0].fields.end_date);
                        cal_jigou.val(n[0].fields.cal_jigou);
                        property.val(n[0].fields.property);
                    }
                });
            });

        });

        $('#myTable').on('change', function () {
            calculateTotal();
        });

        $('#myTable1').on('change', function () {
            calmean();
            calrsd();
        });

        function calculateTotal() {
            $('#myTable tr:gt(0)').each(function () {
                var cell1 = parseFloat($(this).find('td:eq(2) input').val());  // 第一列
                var cell2 = parseFloat($(this).find('td:eq(3) input').val());  // 第二列
                var difference = cell1 - cell2;
                $(this).find('td:eq(4) input').val(difference.toFixed(5));
                //var price = parseFloat($(this).val()) || 0;
                //total += price;
            });

            $('#mean10').val(function () {
                return ((parseFloat($('#c3').val()) + parseFloat($('#c6').val()) + parseFloat($('#c9').val())) / 3).toFixed(5)
            });
            $('#mean100').val(function () {
                return ((parseFloat($('#c12').val()) + parseFloat($('#c15').val()) + parseFloat($('#c18').val())) / 3).toFixed(5)
            });
            $('#mean1000').val(function () {
                return ((parseFloat($('#c21').val()) + parseFloat($('#c24').val()) + parseFloat($('#c27').val())) / 3).toFixed(5)
            });
            $('#mean1').val(function () {
                return ((parseFloat($('#c30').val()) + parseFloat($('#c33').val()) + parseFloat($('#c36').val())) / 3).toFixed(5)
            });

        }


        function calmean() {
            $('#mean').val(function () {
                var mean = ((parseFloat($('#b0').val()) + parseFloat($('#b1').val()) + parseFloat($('#b2').val()) +
                    parseFloat($('#b3').val()) + parseFloat($('#b4').val()) + parseFloat($('#b5').val())) / 6).toFixed(5)
                return mean
            });
        }

        function calrsd() {
            var b0 = parseFloat($('#b0').val());
            var b1 = parseFloat($('#b1').val());
            var b2 = parseFloat($('#b2').val());
            var b3 = parseFloat($('#b3').val());
            var b4 = parseFloat($('#b4').val());
            var b5 = parseFloat($('#b5').val());

            const numbers = [b0, b1, b2, b3, b4, b5];
            const std = stddev(numbers) / mean(numbers) * 100; // 1.4142135623730951
            $('#rsd').val(std);

        }


    });
</script>

{% endblock %}